<?

$pacth="C:/xampp/htdocs/05_NIV/";
require ($pacth.'DataProvider/DataProvider.php');
Class ConntactModule{
	public static function insertContact($_name,$_email,$_country,$_phone,$_address,$_type,$_content){
        $contentencode=htmlentities($_content,ENT_QUOTES,'utf-8');
		$SQLCommand="
        insert 
			`contact`(
				`name`,`email`,`country`,`phone`,`address`,`type`,`content`,`contentencode`,`insert`,`log`
				)
			values(
				'$_name','$_email','$_country','$_phone','$_address','$_type','$_content','$contentencode',now(),''
				)
        ";
        $n=DataProvider::executeNoneSQL($SQLCommand);
        if($n==1) {
            return true;
        }
        return false;
    }
	public static function getContacts($n,$p){
        $SQLCommand="
			SELECT *
			FROM `contact`
			LIMIT ".$p*$n.",$n
		";
        $data=DataProvider::executeSQL($SQLCommand);
        $dt=array();
        if($data!=null) while ($row=$data->fetch_array()){
                array_push($dt, $row);
        }else        return null;
        return $dt;
    }
	public static function getContacts_numpage($n){
        $SQLCommand="select count(*) as numrow from `contact`";
        $data=DataProvider::executeSQL($SQLCommand);
        if($data!=null ) {
            $row=$data->fetch_array();
            return ($row["numrow"]%$n==0)?(int)($row["numrow"]/$n):((int)($row["numrow"]/$n)+1);
        }
        return 0;
    }
}
?>